home *** CD-ROM | disk | FTP | other *** search
- /* GadTools layout toolkit
- **
- ** Copyright © 1993-1994 by Olaf `Olsen' Barthel
- ** Freely distributable.
- */
-
- #include "gtlayout_global.h"
-
- #ifdef DO_GAUGE_KIND
- VOID __regargs
- LTP_DrawGauge(LayoutHandle *handle,ObjectNode *node,LONG percent,BOOLEAN fullRefresh)
- {
- struct RastPort *rp = &handle -> RPort;
-
- if(fullRefresh)
- {
- LONG top = node -> Top + node -> Height - (handle -> RPort . TxHeight + 2);
-
- LTP_SetAPen(rp,handle -> BackgroundPen);
- RectFill(rp,node -> Left,node -> Top,node -> Left + node -> Width - 1,node -> Top + node -> Height - 1);
-
- DrawBevelBox(rp,node -> Left,node -> Top,node -> Width,node -> Height - (handle -> InterHeight + handle -> RPort . TxHeight + 2),
- GT_VisualInfo, handle -> VisualInfo,
- GTBB_Recessed, TRUE,
- TAG_DONE);
-
- LTP_SetPens(rp,handle -> TextPen,0,JAM1);
-
- LTP_PlaceText(handle,"0%",2,node -> Left,top + handle -> RPort . TxBaseline);
- LTP_PlaceText(handle,"100%",4,node -> Left + node -> Width - TextLength(rp,"100%",4),top + handle -> RPort . TxBaseline);
-
- if(node -> Width >= TextLength(rp,"0% 50% 100%",11))
- {
- LONG i,left,total = node -> Width - 2;
-
- LTP_PlaceText(handle,"50%",3,node -> Left + (node -> Width - TextLength(rp,"50%",3)) / 2,top + handle -> RPort . TxBaseline);
-
- top -= handle -> InterHeight;
-
- for (i = 0 ; i < 5 ; i++)
- {
- left = (total * i) / 4;
-
- RectFill(rp,node -> Left + left,top,node -> Left + left + 1,top + 1);
- }
- }
- else
- {
- LONG i,left,total = node -> Width - 2;
-
- top -= handle -> InterHeight;
-
- for (i = 0; i < 3; i++)
- {
- left = (total * i) / 2;
-
- RectFill(rp,node -> Left + left,top,node -> Left + left + 1,top + 1);
- }
- }
- }
-
- if(node -> Special . Gauge . InfoLength && node -> Special . Gauge . InfoText[0])
- {
- LONG height = node -> Height - (1 + handle -> InterHeight + handle -> RPort . TxHeight + 2 + 1);
- LONG width = node -> Width - (2 + 2);
- LONG left = 0;
- LONG right = (width * percent) / 100;
- struct TextExtent Extent;
- LONG len;
-
- if(right)
- {
- LTP_SetAPen(rp,handle -> DrawInfo -> dri_Pens[FILLPEN]);
-
- RectFill(rp,node -> Left + 2 + left,node -> Top + 1,node -> Left + 2 + right - 1,node -> Top + 1 + height - 1);
- }
-
- if(right < width)
- {
- left = right;
- right = width;
-
- LTP_SetAPen(rp,handle -> BackgroundPen);
- RectFill(rp,node -> Left + 2 + left,node -> Top + 1,node -> Left + 2 + right - 1,node -> Top + 1 + height - 1);
- }
-
- if(handle -> DrawInfo -> dri_Pens[FILLTEXTPEN] == handle -> DrawInfo -> dri_Pens[BACKGROUNDPEN])
- {
- if(handle -> DrawInfo -> dri_Pens[TEXTPEN] == handle -> DrawInfo -> dri_Pens[FILLPEN])
- LTP_SetPens(rp,handle -> DrawInfo -> dri_Pens[TEXTPEN],handle -> BackgroundPen,JAM1 | COMPLEMENT);
- else
- LTP_SetPens(rp,handle -> DrawInfo -> dri_Pens[TEXTPEN],handle -> BackgroundPen,JAM1);
- }
- else
- {
- if(handle -> DrawInfo -> dri_Pens[FILLTEXTPEN] == handle -> DrawInfo -> dri_Pens[FILLPEN])
- LTP_SetPens(rp,handle -> DrawInfo -> dri_Pens[FILLTEXTPEN],handle -> BackgroundPen,JAM1 | COMPLEMENT);
- else
- LTP_SetPens(rp,handle -> DrawInfo -> dri_Pens[FILLTEXTPEN],handle -> BackgroundPen,JAM1);
- }
-
- len = TextFit(rp,node -> Special . Gauge . InfoText,strlen(node -> Special . Gauge . InfoText),&Extent,NULL,1,width,32767);
-
- LTP_PlaceText(handle,node -> Special . Gauge . InfoText,len,node -> Left + 2 + (width - Extent . te_Width) / 2,node -> Top + 1 + (height - rp -> Font -> tf_YSize) / 2 + rp -> Font -> tf_Baseline);
-
- LTP_SetPens(rp,handle -> TextPen,handle->BackgroundPen,JAM1);
- }
- else
- {
- if(node -> Current < percent)
- {
- LONG height = node -> Height - (1 + handle -> InterHeight + handle -> RPort . TxHeight + 2 + 1);
- LONG width = node -> Width - (2 + 2);
- LONG left = (width * node -> Current) / 100;
- LONG right = (width * percent) / 100;
-
- if(right)
- {
- LTP_SetAPen(rp,handle -> DrawInfo -> dri_Pens[FILLPEN]);
- RectFill(rp,node -> Left + 2 + left,node -> Top + 1,node -> Left + 2 + right - 1,node -> Top + 1 + height - 1);
- }
- }
- else
- {
- if(node -> Current > percent)
- {
- LONG height = node -> Height - (1 + handle -> InterHeight + handle -> RPort . TxHeight + 2 + 1);
- LONG width = node -> Width - (2 + 2);
- LONG left = (width * percent) / 100;
- LONG right = (width * node -> Current) / 100;
-
- if(right)
- {
- LTP_SetAPen(rp,handle -> BackgroundPen);
- RectFill(rp,node -> Left + 2 + left,node -> Top + 1,node -> Left + 2 + right - 1,node -> Top + 1 + height - 1);
- }
- }
- }
- }
-
- node -> Current = percent;
-
- LTP_PutStorage(node);
- }
- #endif
-